<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>二位码生成器</title>
    <script src="../assets/js/jquery-3.1.1.min.js"></script>
    <script src="../assets/js/qrcode.min.js"></script>
    <link href="../assets/css/animate.css">
</head>
<style>
    body{
        background-color: white;
    }
    #qrcode {
        display: flex;
        justify-content: center;
    }

    .qrcodeLayout {
        margin: 20px;
        text-align: center;
    }

    .qrcodeLayout input {
        outline: none;
        height: 50px;
        width: 50%;
        border: none;
        font-size: x-large;
        text-indent: 15px;
        border-bottom: solid 2px #00BCFF;
        box-shadow:10px 20px 60px rgb(255, 0, 0);
    }

    input::-webkit-input-placeholder {
        /* placeholder颜色  */
        color: #b1b1b1;
    }

    .generateQrcode {
        outline: none;
        border: none;
        height: 50px;
        color: white;
        padding: 5px 20px;
        font-size: large;
        border-radius: 5px;
        background-color: #00BCFF;
        left: 200px;
    }

    .generateQrcode:hover {
        background-color: rgb(28, 174, 228);
    }

    .qrcodeImg {
        padding: 50px;
    }

    .qrcoeTitle {
        color: #3A88FD;
        text-align: center;
    }
</style>

<body>
    <div class="qrcoeTitle">
        <h1>二维码生成器</h1>
    </div>
    <div class="qrcodeLayout">
        <input value="" placeholder="请输入需要生成二维码的值" id="qrcodeInput">
        <button class="generateQrcode" onclick="generateQrcode()">生成</button>
    </div>
    <div id="qrcode" class="qrcodeImg" style="display: none;"></div>
</body>
<script>
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width: 100,
        height: 100
    });
    // 键盘事件
    $('#qrcodeInput').keydown(function (e) {
        if (e.keyCode == 13) {
            generateQrcode()
        }
    })
    // 执行方法
    function generateQrcode() {
        $('#qrcode').hide()
        if ($('#qrcodeInput').val().length <= 0) {
            $('#qrcodeInput').attr('placeholder', '不输入值你想干啥，跟你玩呐！')
        } else {
            $('#qrcode').show()
            qrcode.makeCode($('#qrcodeInput').val())
        }
    }
</script>

</html>